package com.lanlian.cayman.fragment;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lanlian.cayman.R;
import com.lanlian.cayman.bean.MyContractBean;
import com.lanlian.cayman.utils.NumberManager;

/**
 * <pre>
 *     author :
 *
 *     date   : 2018/8/16 10:17
 *     desc   :  k底部切换item
 *     version: 1.0
 * </pre>
 */
public class GearFragment extends LinearLayout {

    private TextView mTvOpen;
    private TextView mTvClosingPrice;
    private TextView mTvHighPrice;
    private TextView mTvLowPrice;
    private TextView mTvTotalNum;
    private TextView mTvLimitUpPrice;
    private TextView mTvLimitDownPrice;
    private TextView mTvZuoJie;
    private Activity act;

    public GearFragment(Context context) {
        super(context);
        act = (Activity) context;
        View view = act.getLayoutInflater().inflate(R.layout.fragment_gear, null);
        initView(view);
        addView(view);
    }

    protected void initView(View view) {
        mTvZuoJie = view.findViewById(R.id.tv_zuojie);
        mTvOpen = view.findViewById(R.id.tv_open);
        mTvClosingPrice = view.findViewById(R.id.tv_ClosingPrice);
        mTvHighPrice = view.findViewById(R.id.tv_HighPrice);
        mTvLowPrice = view.findViewById(R.id.tv_LowPrice);
        mTvTotalNum = view.findViewById(R.id.tv_TotalNum);
        mTvLimitUpPrice = view.findViewById(R.id.tv_LimitUpPrice);
        mTvLimitDownPrice = view.findViewById(R.id.tv_LimitDownPrice);
    }

    public void setData(MyContractBean mb) {
        mTvOpen.setText(mb.open);
        mTvClosingPrice.setText(mb.ClosingPrice);
        mTvHighPrice.setText(mb.HighPrice);
        mTvLowPrice.setText(mb.LowPrice);
        mTvTotalNum.setText(NumberManager.getString4or5("1", mb.TotalNum, 0));
        mTvLimitUpPrice.setText(mb.LimitUpPrice);
        mTvLimitDownPrice.setText(mb.LimitDownPrice);
        mTvZuoJie.setText(mb.SettlePrice);

        if (NumberManager.isDaYu(NumberManager.getString4or5("1", mb.TotalNum, 0), "0") <= 0) {
            mTvTotalNum.setText("--");
        }
        if (NumberManager.isDaYu(mb.LimitUpPrice, "0") <= 0) {
            mTvLimitUpPrice.setText("--");
        }
        if (NumberManager.isDaYu(mb.LimitDownPrice, "0") <= 0) {
            mTvLimitDownPrice.setText("--");
        }

    }

}
